home *** CD-ROM | disk | FTP | other *** search
- #include "wand_head.h"
-
- extern int debug_disp;
- extern long dictsize; /* bjr */
- extern FILE *dictfp; /* bjr */
- extern WINDOW *messagewin;
-
- void scrn_passwd(num, passwd) /* reads password num into passwd */
- int num;
- char *passwd;
- {
- long position;
-
- position = PASSWD;
- while (position >= dictsize)
- position -= dictsize;
- fseek(dictfp,position,SEEK_SET);
- while (fgetc(dictfp) != '\n' && !feof(dictfp));
- /* read a word into passwd */
- if (fscanf(dictfp,"%s\n",passwd) == EOF) {
- rewind(dictfp);
- fscanf(dictfp,"%s\n",passwd);
- }
- }
-
- void showpass(num)
- int num;
- {
- long position;
- char correct[20];
- char buffer[100];
- char ch;
- wmove(messagewin,0,0);
- scrn_passwd(num,correct);
- sprintf(buffer,"The password to jump to level %d ( using ~ ) is : %s \n",(num+1),correct);
- waddstr(messagewin,buffer);
- waddstr(messagewin,"PRESS ANY KEY TO REMOVE IT AND CONTINUE \n");
- wrefresh(messagewin);
- ch = wgetch(messagewin);
-
- wmove(messagewin,0,0);
- waddstr(messagewin," \n");
- waddstr(messagewin," ");
- wrefresh(messagewin);
-
- }
-
- int jumpscreen(num)
- int num;
- {
- char word[20], buffer[100], correct[20];
- int index = 0, input;
- int scrn;
- wclear(messagewin);
- wmove(messagewin,0,0);
- waddstr(messagewin,"Enter number of desired level:");
- wrefresh(messagewin);
- scrn = getnum();
-
- if (dictsize) { /* if passwords are enabled */
- wmove(messagewin,0,0);
- waddstr(messagewin,"Please enter password of screen to jump to:");
- wrefresh(messagewin);
- while (((word[index++] = wgetch(messagewin)) != '\n')
- && (index < 19))
- {
- waddch(messagewin,'*');
- wrefresh(messagewin);
- }
- word[--index]='\0';
- wmove(messagewin,0,0);
- waddstr(messagewin,
- "Validating... \n");
- wrefresh(messagewin);
-
- if (strcmp(word,MASTERPASSWORD) == 0) {
- scrn_passwd(scrn-1,correct);
- sprintf(buffer,"Certainly master, but the correct word is %s. \n",correct);
- wmove(messagewin,0,0);
- waddstr(messagewin,buffer);
- waddstr(messagewin,"PRESS ANY KEY TO REMOVE IT AND CONTINUE \n");
- wrefresh(messagewin);
- wgetch(messagewin);
- wmove(messagewin,0,0);
- waddstr(messagewin," \n");
- waddstr(messagewin," ");
- wrefresh(messagewin);
- return scrn;
- }
- }
-
- if (scrn <= num) {
- wmove(messagewin,0,0);
- waddstr(messagewin,"No way, Jose! Back-jumping is prohibited!");
- wrefresh(messagewin);
- return num;
- }
-
- if (!dictsize) { /* if passwords are disabled */
- wmove(messagewin,0,0);
- waddstr(messagewin," ");
- return scrn;
- }
-
- scrn_passwd(scrn-1,correct);
- if (strcmp(correct,word) == 0) {
- wmove(messagewin,0,0);
- waddstr(messagewin,"Password Validated..... Jumping to desired screen. ");
- wrefresh(messagewin);
- return scrn;
- }
- wmove(messagewin,0,0);
- waddstr(messagewin,"PASSWORD NOT RECOGNISED! ");
- wrefresh(messagewin);
- /*
- if (!debug_disp)
- move(16,0);
- else
- move(18,0);
- addstr(" ");
- */
- return num;
- }
-
- int getnum()
- {
- char ch;
- int num = 0;
-
- for (ch = wgetch(messagewin), waddch(messagewin,ch),
- wrefresh(messagewin); ch >= '0' && ch <= '9';
- ch = wgetch(messagewin), waddch(messagewin,ch), wrefresh(messagewin))
- num = num * 10 + ch - '0';
- return num;
- }
-